package com.fang.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fang.entity.SysRole;
import com.fang.mapper.SysRoleMapper;
import com.fang.service.SysRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Fang Ruichuan
 * @since 2022-08-27
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {

    @Override
    public List<SysRole> listRolesByUserId(Long userId) {
        List<SysRole> list = this.list(Wrappers.<SysRole>lambdaQuery()
                .inSql(SysRole::getId, "select role_id from sys_user_role where user_id = " + userId));
        return list;
    }
}
